/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-03-31
 * Time: 19:30
 */
class MyThread8 extends Thread {

    @Override
    public void run() {
        try {
            Thread.sleep(20000); // 子线程睡眠
        } catch (InterruptedException e) {
            //e.printStackTrace();
            System.out.println("中断");
        }
    }
}

public class test_2 {
    public static void main(String[] args) throws InterruptedException {

        MyThread8 thread = new MyThread8();

        thread.start();
        thread.interrupt(); // 由主线程中断了一个子线程
    }
}
